package core.error
{
	import debug.Log;
	
	import flash.events.EventDispatcher;
	
	public class Errors
	{
		//START
		
		//PROPERTY
		public var description:String;
		
		public var info:String;
		
		public static var syntaxErrorHandler:Function = _syntaxErrorHandler;
		
		public static var ioErrorHandler:Function = _ioErrorHandler;
		
		public static var securityErrorHandler:Function = _securityErrorHandler;
		
		public static var viewMissingHandler:Function = _viewMissingHandler;
		
		public static var modelMissingHandler:Function = _modelMissingHandler;
		
		public static var serverRefuseHandler:Function = _serverRefuseHandler;
		
		public static var elementMissHandler:Function = _elementMissHandler;
		
		
		//CONSTRUCTOR
		public function Errors(info:String = "")
		{
						
			this.info = info;
						
		}
		
		//METHODS
		
		public static function register(target:EventDispatcher):void
		{
			
			target.addEventListener(ErrorEvents.SYNTAX_ERROR,Errors.syntaxErrorHandler,false,0,true);
			
			target.addEventListener(ErrorEvents.IO_ERROR,Errors.ioErrorHandler,false,0,true);
			
			target.addEventListener(ErrorEvents.SECURITY_ERROR,Errors.securityErrorHandler,false,0,true);		
			
			target.addEventListener(ErrorEvents.VIEW_METHOD_MISSING,viewMissingHandler,false,0,true);
			
			target.addEventListener(ErrorEvents.MODEL_METHOD_MISSING,modelMissingHandler,false,0,true);
			
			target.addEventListener(ErrorEvents.SERVER_REFUSE,serverRefuseHandler,false,0,true);
			
			target.addEventListener(ErrorEvents.ELEMENT_MISS,elementMissHandler,false,0,true);
			
		}
				
		//Handlers
		
		static private function _syntaxErrorHandler(evt:ErrorEvents):void
		{
			
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
			
		}
		
		static private function _ioErrorHandler(evt:ErrorEvents):void
		{
						
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
			
		}
		
		static private function _securityErrorHandler(evt:ErrorEvents):void
		{
			
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
					
		}
		
		static private function _viewMissingHandler(evt:ErrorEvents):void
		{
			
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
					
		}
		
		
		static private function _modelMissingHandler(evt:ErrorEvents):void
		{
			
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
					
		}
		
		static private function _serverRefuseHandler(evt:ErrorEvents):void
		{
			
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
					
		}
		
		static private function _elementMissHandler(evt:ErrorEvents):void
		{
			
			Log.log(evt.type, evt.error.info,Log.LOG_ERROR);
			
		}
		
		//END
	}
}